<?php 
/* represents the ebay api 
 * and allows searching ebay
 * for products and the links
 * to these products get the
 * affiliate link attached.
 * 
 * see docs here:
 * http://developer.ebay.com/DevZone/finding/Concepts/FindingAPIGuide.html#useaffiliate
 * 
 * */
class ebay{
	// defines the ebay api service url
	private $url = "http://svcs.ebay.com/services/search/FindingService/v1";
	private $version = "1.0.0"; // api version to use
	
 	
	/* searches the ebay api for products */
	public function findProducts($keyword,$count="3"){
		// build the request url for this keyword
		$apiUrl = $this->url."?OPERATION-NAME=findItemsByKeywords"
				."&SERVICE-VERSION=".$this->version
				."&SECURITY-APPNAME=".CONFIG_EBAY_APPID
				."&GLOBAL-ID=".CONFIG_EBAY_GLOBALID
				."&keywords=".urlencode($keyword)
				."&paginationInput.entriesPerPage=".$count
				."&affiliate.trackingId=".CONFIG_EBAY_CAMPAIGNID
				."&affiliate.networkId=".CONFIG_EBAY_NETWORKID;

		// load the xml and parse it
		return simplexml_load_file($apiUrl);		
	}
}
?>